package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.entity.SpuImage;
import com.atguigu.gmall.product.service.SpuImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lfy
 * @Description
 * @create 2023-07-14 14:13
 */
@RequestMapping("/admin/product")
@RestController
public class SpuImageRestController {


    @Autowired
    SpuImageService spuImageService;
    /**
     * 查询某个SPU的所有图片
     * @return
     */
    @GetMapping("/spuImageList/{spuId}")
    public Result spuImageList(@PathVariable("spuId")Long spuId){

        List<SpuImage> spuImages = spuImageService.lambdaQuery()
                .eq(SpuImage::getSpuId, spuId)
                .list();

        return Result.ok(spuImages);
    }
}
